{extend name="foxcms" /}

{block name="css"}
{/block}

{block name="body"}
<input type="hidden" value="{$columnLevel.id}" id="id"/>
<input type="hidden" value="{$ts}" id="ts"/>
<div class="foxcms-content-inner">
	<!-- page content -->
	<div class="contact-way-content">
		<div class="section section-panel">
			<div class="section-title">栏目层级设置</div>
			<div class="section-main">

				<div class="section-main-item">
					<div class="foxui-input-group">
						<div class="input-label">
							<label class="foxui-required">栏目层级：</label>
						</div>
						<div class="input-box">
							<div class="foxui-radio-group level">
								<div class="foxui-radio {if $columnLevel.level == 1} is-checked {/if}">
                                    <span class="foxui-radio-input">
                                        <i class="foxui-radio-icon"></i>
                                        <input type="radio" value="1"/>
                                    </span>
									<span class="foxui-radio-label">一级栏目</span>
								</div>

								<div class="foxui-radio {if $columnLevel.level == 2} is-checked {/if}">
                                    <span class="foxui-radio-input">
                                        <i class="foxui-radio-icon"></i>
                                        <input type="radio" value="2"/>
                                    </span>
									<span class="foxui-radio-label">二级栏目</span>
								</div>

								<div class="foxui-radio {if $columnLevel.level == 3} is-checked {/if}">
                                    <span class="foxui-radio-input">
                                        <i class="foxui-radio-icon"></i>
                                        <input type="radio" value="3"/>
                                    </span>
									<span class="foxui-radio-label">三级栏目</span>
								</div>
							</div>
						</div>
					</div>
					<p class="input-box-info">
						切换栏目级别需要重新设置文章的栏目从属关系，以免导致用户浏览不到相关文章
					</p>
				</div>

				<div class="section-main-item">
					<div class="foxui-input-group">
						<div class="input-label">
							<label>栏目图片：</label>
						</div>
						<div class="input-box display-flex foxui-align-items-center">
							<p class="switch-label">是否开启缩略图</p>
							<div class="is_thumb foxui-switch {if $columnLevel.is_thumb == 1} is-checked {/if}">
								<input type="checkbox" checked="checked" value="{if $columnLevel.is_thumb == 1} 1 {/else} 0{/if}" class="foxui-switch-input">
								<span class="foxui-switch-core"></span>
							</div>
						</div>
					</div>
				</div>

			</div>
		</div>
	</div>
</div>

<div class="foxcms-content-footer">
	<button class="is-long foxui-size-small foxui-solid-primary" id="save">保存</button>
</div>
{include file="footed-copy"/}
{/block}


{block name="js"}

<script>

	//保存
	$('#save').click(function() {

		let level = $('.level .foxui-radio.is-checked input').val();
		//是否开启缩略图 0：未；1：开启
		let is_thumb = ($('.is_thumb.is-checked').length > 0)?1:0;
		let id = $("#id").val();
		let data = {'level': level, 'is_thumb': is_thumb, id: id};

		foxui.dialog({
			title: '保存',
			content: '您确定要保存吗',
			cancelText: '取消',
			confirmText: '保存',
			confirm: function(callback) {
				ajaxR('save','post',data,{},function (res) {
					if (res.code == 1) {
						foxui.message({
							type:'success',
							text:res.msg
						})
						setTimeout('myrefresh()', 100); //指定10秒刷新一次
					} else {
						foxui.message({
							type:'warning',
							text:res.msg
						})
					}
				}, function (res) {
					foxui.message({
						type:'warning',
						text:res.msg
					})
				})
				callback();
			},
			cancel: function() {
				foxui.message({
					type: 'warning',
					text: '取消操作'
				})
			},
		});

	})
</script>

{/block}
